<form method="post" action="index.php?app=b2c&ctl=admin_goods_cat&act=save" id='add-category-form'>
<div class="tableform">
    <div class="division">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <th><{t}>分类名称：<{/t}>
            <{if $cat.cat_id }><input type="hidden" value="<{$cat.cat_id}>" name="cat[cat_id]" /></th><{/if}>
          <td><input type="text" value="<{$cat.cat_name|escape:'html'}>" name="cat[cat_name]" vtype='required' class='x-input'/>
            <{$cat_name}></td>
        </tr>
        <tr>
          <th><{t}>上级分类：<{/t}></th>
          <td><{input type="select" name="cat[parent_id]" style="font-size:12px;" required='1' value=$cat.parent_id rows=$catList valueColumn="cat_id" labelColumn="cat_name"}>
            <span class="notice-inline"><{t}>顶级分类请选择“无”<{/t}></span></td>
        </tr>
        <tr>
          <th><{t}>商品类型：<{/t}></th>
          <td><select name="cat[type_id]">
              <{foreach from=$gtypes item=type}> <option value="<{$type.type_id}>" <{if $type.type_id == $cat.type_id}>selected="selected"<{/if}>><{$type.name}>
              </option>
              <{/foreach}>
            </select></td>
        </tr>
<!--tag_foreign_cat_disable-->
		<tr>
		  <th><{t}>模板：<{/t}></th>
		  <td>
		  <{template_filter type="gallery" selected=$gallery_setting.gallery_template name="cat[gallery_setting][gallery_template]"}></td>
		</tr>
        <tr>
          <th><{t}>排序：<{/t}></th>
          <td><input style="width:50px;" vtype="unsigned" class="inputstyle" value="<{if $cat.p_order}> <{$cat.p_order}> <{else}>0<{/if}>" name="cat[p_order]" class="_x_ipt"/>
            <span class="notice-inline"><{t}>数字越小越靠前<{/t}></span></td>
        </tr>

        <tr>
          <th><{t}>TITLE<br>
            (页面标题)<{/t}></th>
          <td><input type="text" name="cat[seo_info][seo_title]" style="width:90%" class="inputstyle" maxlength="100" value="<{$seo_info.seo_title}>"></td>
        </tr>
          <tr>
          <th><{t}>META_KEYWORDS<br>
            (页面关键词)<{/t}></th>
          <td><input type="text" name="cat[seo_info][seo_keywords]" style="width:90%" class="inputstyle" maxlength="100" value="<{$seo_info.seo_keywords}>"></td>
        </tr>
        <tr>
          <th><{t}>META_DESCRIPTION<br>
            (页面描述)<{/t}></th>
          <td><textarea name="cat[seo_info][seo_description]" rows=4 style="width:90%" class="inputstyle" cols=35 maxlength=255/><{$seo_info.seo_description}></textarea></td>
        </tr>

      </table>
    </div>
<!--tag_foreign_cat_seo-->

<!--tag_foreign_goods_cat-->

</div>




<div class="table-action">
	<{button label=$___b2c="保存"|t:'b2c'  type="submit" }>
	<!--<{button label="保存并继续添加" type="button" id='easy-save-category'}>-->
	<{button class="btn-secondary " label=$___b2c="取消"|t:'b2c' isclosedialogbtn="true" onclick="W.page('index.php?app=b2c&ctl=admin_goods_cat&act=index')" }>
</div>

<script>
           $E('#add-category-form input[name^=cat[cat_name]').addEvent('keydown',function(e){

               if(e.key=='enter'){


                 e.stop();

                   //return $('easy-save-category').fireEvent('click',{stop:$empty});
               }

           });

           $('add-category-form').store('target',{onComplete:function(){

                  if(gms=$('g_menu_sec_2')){
                      gms.empty();
                      gms.retrieve('update',$empty)();
                  }


           }});

			if($('easy-save-category'))
           $('easy-save-category').addEvent('click',function(e){
                    e.stop();
                    var _form=this.form;

                    var cname=$E('#add-category-form input[name^=cat[cat_name]');
                    var value=cname.get('value').clean().trim();

                    var cid=$E('#add-category-form input[name^=cat[cat_id]');
                    if(cid) cid.remove();

                    if(!value)return MessageBox.error('<{t}>分类名称为不能为空.<{/t}>');
                    if(this.retrieve('tempname',[]).contains(value)){
                       if(!confirm('<{t}>您刚才已经添加了分类:<{/t}>"'+value+'"<{t}>\n要重复添加么?<{/t}>'))return;
                    }

                    this.retrieve('tempname',[]).include(value);

                    if(!$(_form).get('target')){

                      var _target={
                         update:'messagebox'
                      }
                       _form.set('target',JSON.encode(_target));
                    }
                    _form.fireEvent('submit',e).erase('target');

           });
			$('add-category-form').store('target',{
				onComplete:function(){
					if($('add-category-form').getParent('.dialog'))
					$('add-category-form').getParent('.dialog').retrieve('instance').close();
				}
			});
        </script>
</form>
